var mysql      = require('mysql');
var connection = mysql.createConnection({
  host     : 'localhost',
  user     : 'root',
  password : 'root',
  database : 'studata'
});
 
connection.connect();
 
// connection.query('SELECT * from t_students', function (error, results, fields) {
//   if (error) throw error;
//   console.log('The result is: ', results);
// });
 
// connection.end();

exports.myDb = function (sql) {
    var promise = new Promise(function (reslove, reject) {
        connection.query(sql, function (error, results, fields) {
            if (error) reject
            reslove(results)
        })
    })

    return promise
}
